# lib/stair_master/concerns/tests.rb
##
##
##
module StairMaster
  module Concerns
    module Tests
      extend ActiveSupport::Concern

      included do
        helper_method :on_first_step?,
                      :on_last_step?
      end

      ## Methods ------------------------------------------
      def on_last_step?
        @stair_master_on_last_step ||= is_last_step?(current_step_name)
      end

      def on_first_step?
        @stair_master_on_first_step ||= is_first_step?(current_step_name)
      end

      def is_last_step?(step_name)
        step_name == available_steps.last
      end

      def is_first_step?(step_name)
        step_name == available_steps.first
      end

      def step_should_be_skipped?(step=nil)
        step = step.nil? ? current_step : step
        step.skip?(self)
      end
    end
  end
end